package com.qiang;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test12 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("林青霞");
        list.add("林青霞");
        list.add("林青霞");
        list.add("林青霞");
        list.add("张曼玉");
        list.add("王祖贤");
        list.add("王祖贤");
        list.add("王祖贤");
        list.add("柳岩");
        list.add("张敏");
        list.add("张无忌");
        /*Stream<String> distinct = list.stream().distinct();
        distinct.forEach((String s) -> {
            System.out.println(s);
        });*/

        Set<String> l = list.stream().filter(s -> s.startsWith("王")).filter(s -> s.length() == 3).collect(Collectors.toSet());
        for (String s : l) {
            System.out.println(s);
        }

        List<String> ll = list.stream().filter(s -> s.startsWith("林")).filter(s -> s.length() == 3).collect(Collectors.toList());
        for (String s : ll) {
            System.out.println(s);
        }
    }
}
